package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Chatroom;
import cn.wolfcode.trip.base.domain.UserChatRoom;
import cn.wolfcode.trip.base.service.IChatRoomService;
import cn.wolfcode.trip.base.service.IUserChatRoomService;
import org.omg.PortableInterceptor.USER_EXCEPTION;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ChatroomController class
 *
 * @author lishuanwang
 * @date 2019/5/31
 */
@RestController
@RequestMapping("chatrooms")
public class ChatroomController {

    @Autowired
    private IChatRoomService chatRoomService;
    @Autowired
    private IUserChatRoomService userChatRoomService;

    @GetMapping("{userId}")
    public List<Chatroom> listChatRoomByUserId(@PathVariable Long userId){
        System.out.println(userId);
        List<Chatroom> userChatRoom = userChatRoomService.listChatRoomsByUserId(userId);
        return userChatRoom;
    }
}
